package com.example.testactivity;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class SecondActivity extends Activity {

	// 退出按钮
	private Button secondButton;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		Log.v("SecondActivity", "onCreate");
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_second);
		secondButton = (Button) findViewById(R.id.secondButton);
		// 为退出按钮设置单击事件
		secondButton.setOnClickListener(new ButtonListener());
	}

	@Override
	protected void onStart() {
		super.onStart();
		Log.v("SecondActivity", "onStart");
	}

	@Override
	protected void onResume() {
		super.onResume();
		Log.v("SecondActivity", "onResume");
	}

	@Override
	protected void onPause() {
		super.onPause();
		Log.v("SecondActivity", "onPause");
	}

	@Override
	protected void onStop() {
		super.onStop();
		Log.v("SecondActivity", "onStop");
	}

	@Override
	protected void onDestroy() {
		super.onDestroy();
		Log.v("SecondActivity", "onDestroy");
	}

	class ButtonListener implements OnClickListener {

		@Override
		public void onClick(View v) {
			finish();// 关闭当前Activity，也就是退出
		}

	}
}